package com.example.trafficexam2.dao;

import android.content.Context;

import com.example.trafficexam2.bean.Sense;
import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by Administrator on 2018/12/5/005.
 */

public class SenseDao {
    private Context context;
    private Dao<Sense,Integer> dao;
    private List<Sense> senseList;


    public SenseDao(Context context){
        this.dao = DatabaseHelper.getInstance(context).getDao(Sense.class);
    }

    public void insert(Sense data){
        try {
            dao.create(data);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public List<Sense> queryAllSense(){
        try {
            senseList = dao.queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return  senseList;
    }
}
